<?php
require_once 'mods/class_file.php';
require_once 'mods/class_repairs_files.php';

$id = intval($_GET['id']);
if ($id)
{
    $objFile = new File();
    $objFile->load($id);
    $name = $objFile->__get('name');
    $size = $objFile->__get('size');
    $type = $objFile->__get('type');
    $extension = $objFile->__get('extension');
    $repairsFile = new RepairsFiles();
    $realFileName = $repairsFile->load($id);
    $folderName = $repairsFile->getRepair();

    $filePath = '/data/atm_files/repairs/' . $folderName . '/' . $realFileName . '.' . $extension;

    if(@$fp = fopen($filePath, "rb", 0))
    {
       $picture = fread($fp,filesize($filePath));
       fclose($fp);
       // base64 encode the binary data, then break it
       // into chunks according to RFC 2045 semantics
       $base64 = chunk_split(base64_encode($picture));
       $tag = '<img ' .
              'src="data:image/jpeg;base64,' . $base64 .
              '" />';
       print $tag;
    }
}
